/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dnstry;

/**
 *
 * @author Claudiu
 */
public class DnsEntry {
    private String name;
    private int type;
    private int class_;
    private int ttl;
    private int len;
    private byte[] content;
    private int[] contentInt;
    private String data;
    public DnsEntry()
    {}

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the type
     */
    public int getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(int type) {
        this.type = type;
        System.out.println("type : " +type);
    }

    /**
     * @return the class_
     */
    public int getClass_() {
        return class_;
    }

    /**
     * @param class_ the class_ to set
     */
    public void setClass_(int class_) {
        this.class_ = class_;
    }

    /**
     * @return the ttl
     */
    public int getTtl() {
        return ttl;
    }

    /**
     * @param ttl the ttl to set
     */
    public void setTtl(int ttl) {
        this.ttl = ttl;
        System.out.println("ttl : "+ ttl);
    }

    /**
     * @return the len
     */
    public int getLen() {
        return len;
    }

    /**
     * @param len the len to set
     */
    public void setLen(int len) {
        this.len = len;
    }

    /**
     * @return the content
     */
    public byte[] getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(byte[] content) {
        this.content = content;
        for (int i=0;i<content.length;i++)
        {
            System.out.println("c: "+i+ "="+content[i]);
        }
    }
        public void setContentInt(int[] content) {
        this.contentInt = content;
        for (int i=0;i<content.length;i++)
        {
            System.out.println("c: "+i+ "="+content[i]);
        }
    }

    /**
     * @return the data
     */
    public String getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(String data) {
        this.data = data;
    }
    public String toString()
    {
        String ret="";

        ret+=" type ";
        ret+=type;
        ret+=" class ";
        ret+= class_;
        ret+=" ttl ";
        ret+=ttl;
        ret+=" len ";
        ret+=len;
        ret+=" content ";
        for (int i=0;i<contentInt.length;i++)
        {
           if(type == 1)
           {
             ret+=" "+contentInt[i];
           }else
           {
            ret+=" "+(char)contentInt[i];
           }
        }
        return ret;

    }
    public String getIP()
    {
        String ret="";
        if ( type ==1)
        for (int i=0;i<4;i++)
             ret+=contentInt[i]+".";
        return ret;
    }



}
